import 'package:cat_eye/base/base_refresh_view_model.dart';
import 'package:cat_eye/bean/home_body_bean.dart';
import 'package:cat_eye/config/string_config.dart';
import 'package:cat_eye/config/url_config.dart';

/*
* @Package: view_model.find_view_model
* @ClassName: find_info_view_model
* @Author: szj
* @CreateDate: 8/4/21 5:56 PM
* TODO 发现-资讯ViewModel
*/
class FindInfoViewModel extends BaseRefreshViewModel {
  //加载更多Url
  String loadMoreUrl = "";

  List<ItemList> itemList = [];

  @override
  String get httpLoadMoreUrl => "$loadMoreUrl&vc=6030000&deviceModel=${StringConfig.isEquipment}";

  @override
  String get httpUrl => "${UrlConfig.newsUrl}${StringConfig.isEquipment}";

  @override
  void refresh() {
    if (itemList.length > 0) itemList.clear();
    super.refresh();
  }

  @override
  void successJsonData(json) {
    var issueList = IssueList.fromJson(json);

    itemList.addAll(issueList.itemList);

    loadMoreUrl = issueList.nextPageUrl;
  }
}
